public class NumberOfWeeks {

    public static void main(String[] args) {
        NumberOfWeeks numberOfWeeks = new NumberOfWeeks();
        int[] nums = {1,2,3};
        System.out.println(numberOfWeeks.numberOfWeeks(nums));
    }

    public long numberOfWeeks(int[] milestones) {
        int sum = 0;
        int max = 0;
        for (int i = 0; i < milestones.length; i++) {
            sum += milestones[i];
            max = Math.max(max, milestones[i]);
        }
        if (max <= (sum - max) + 1) {
            return sum;
        } else {
            return (sum - max) * 2 + 1;
        }
    }
}
